package com.zyk.leetcode;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @author zhangsan
 * @date 2021/4/21 17:08
 */
public class C78 {

    LinkedList<Integer> t = new LinkedList<>();
    List<List<Integer>> ans = new ArrayList<>();

    public List<List<Integer>> subsets(int[] nums) {
        dfs(0, nums);
        return ans;
    }

    public void dfs(int cur, int[] nums) {
        if (cur == nums.length) {
            ans.add(new ArrayList<>(t));
            return;
        }
        t.add(nums[cur]);
        dfs(cur + 1, nums);
        t.removeLast();
        dfs(cur + 1, nums);
    }


    public static void main(String[] args) {
        C78 test = new C78();
        int[] nums = {1,2,3};
        System.out.println(test.subsets(nums));
    }

}
